package com.zzyl.framework.config;

//import com.aliyun.tearpc.Client;
//import com.aliyun.tearpc.models.Config;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.iot20180120.Client;
import com.zzyl.framework.config.properties.AliIoTConfigProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IotClientConfig {

    @Autowired
    private AliIoTConfigProperties aliIoTConfigProperties ;
    @Bean
    public Client client()throws Exception {
//        accessKeyId: LTAI5tDJYvT8XPkcMjXMPMoh
//        accessKeySecret: vUy24DshbDtV0Hg0gspA4mWwiTdd19
//        consumerGroupId: DEFAULT_GROUP
//        regionId: cn-shanghai
//        iotInstanceId: iot-06z00b1spcnpumg
//        host: iot-06z00b1spcnpumg.mqtt.iothub.aliyuncs.com
        aliIoTConfigProperties.setAccessKeyId("LTAI5tDJYvT8XPkcMjXMPMoh");
        aliIoTConfigProperties.setAccessKeySecret("vUy24DshbDtV0Hg0gspA4mWwiTdd19");
        aliIoTConfigProperties.setConsumerGroupId("DEFAULT_GROUP");
        aliIoTConfigProperties.setRegionId("cn-shanghai");
        aliIoTConfigProperties.setIotInstanceId("iot-06z00b1spcnpumg");
        aliIoTConfigProperties.setHost("iot-06z00b1spcnpumg.mqtt.iothub.aliyuncs.com");
//

        Config config = new Config();
        config.setAccessKeyId(aliIoTConfigProperties.getAccessKeyId());
        config.setAccessKeySecret(aliIoTConfigProperties.getAccessKeySecret());
        config.setRegionId(aliIoTConfigProperties.getRegionId());
        return new Client(config);
    }


}
